Motivation

The flow over a Mach 3 step is a well-studied problem in CFD (computational fluid dynamics), making it a good choice for convergence and performance studies. A simple set of studies are undertaken here.

Implementation

We implement all simulation with OpenFoam, analysis with Paraview and Python3, and documentation code in R Xie, Dervieux, and Riederer (2020).

Theory : Governing Equations















Mesh Assembly : Preliminaries

We assemble a preliminary solution at \(T = 4s\) with 6300 cells, for the following inlet conditions: \(M=3\),\(p=1Pa\),\(T=1K\),\(\rho = \gamma \frac{kg}{m^3}\) with \(\gamma = 1.4\). All results have been non-dimensionalized: velocity, pressure, density and temperature are all measured with respect to inlet conditions.

Mesh

Density

Velocity X,Y, Magnitude

Pressure

Mach Number

Speed of Sound

Temperature

Convergence

Three meshes were used, with increasing numbers of cells and smaller timesteps, as follows: (note the timesteps are approximate as the solver, RhoCentralFoam, adjusts timesteps as necessary to maintain a maximum Courant number of 0.2).

Run_10_64 : 6300 cells, dx = 0.04000, dt = 0.00110
Run_20_64 : 25200 cells, dx = 0.02000, dt = 0.00056
Run_32_64 : 64512 cells, dx = 0.00625, dt = 0.00034

Improvements in Pressure, Density, and Y-Velocity with increasing resolution:

Note the upper shock turbulent features (the small waves), and how they resolve much more appropriately with higher resolution meshes.

Pressure (from Run_10 to Run_32):

Density:

Y-velocity:

Wall Distributions w.r.t Resolution Levels:

Pressure, density, x-velocity, y-velocity, and temperature are reported in that order. Note that the walls are traversed from left to right, first the horizontal wall prior to the step, then the vertical step wall (traversing upward), then the horizontal wall (the step itself), and finally the upper horizontal wall.

Convergence is shown through decreasing h (the spatial step-size).

Pressure:

Density:

X-velocity:

Y-velocity:

Temperature:

Stagnation Pressure at Step

Note from the first two pressure plots, the pressure at the base of the step is slightly over 12Pa. The simulation measures a value of about 12.05Pa, which is in agreement with the theoretical calculation performed earlier.

Parallel Performance Improvements

Define the speedup as the time taken for one processor (\(T(1)\)) divided by the time taken for \(P\) processors (\(T(P)\)). Similarly, let the parallel efficiency \(\eta\) be the speedup divided by \(P\).

Note that the tables report the total \(T(P)\), not that of single steps. The single step \(T(P)\) is used instead for the plots.

On a mesh of 64512 cells, for \(P\) ranging from 1 to 64 in steps of 2, the following scaling is obtained.

\(T(P)\) Speedup \(\eta\)
4870.28 1.0000 1.0000
2745.57 1.7738 0.8869
1493.30 3.2614 0.8154
0865.21 5.6290 0.7036
0513.54 9.4837 0.5927
0337.99 14.409 0.4503
0247.94 19.642 0.3069

A slightly improved scaling is obtained for a mesh of 1000188 cells.

\(T(P)\) Speedup \(\eta\)
270763.66 1.0000 1.0000
034192.10 2.0239 1.0119
034129.40 3.9783 0.9946 039850.40 7.6188 0.9524
021542.00 14.094 0.8808
012256.70 24.765 0.7739
008170.29 37.171 0.5808

Clearly the larger mesh case scales much more nicely, which can be expected due to the more even load distribution.

References

Allaire J, Xie Y, McPherson J, Luraschi J, Ushey K, Atkins A, Wickham H, Cheng J, Chang W, Iannone R (2021). Rmarkdown: Dynamic Documents for r. Retrieved from https://CRAN.R-project.org/package=rmarkdown
Bengtsson H (2021). R.utils: Various Programming Utilities. Retrieved from https://github.com/HenrikBengtsson/R.utils
Urbanek S (2021). Jpeg: Read and Write JPEG Images. Retrieved from http://www.rforge.net/jpeg/
Xie Y (2013). animation: An R Package for Creating Animations and Demonstrating Statistical Methods.” Journal of Statistical Software, 53(1), 1–27. Retrieved from https://doi.org/10.18637/jss.v053.i01
Xie Y (2014). “Knitr: A Comprehensive Tool for Reproducible Research in R.” In Implementing reproducible computational research, eds. V Stodden, F Leisch, and RD Peng,. Chapman; Hall/CRC. Retrieved from http://www.crcpress.com/product/isbn/9781466561595
Xie Y (2015). Dynamic Documents with R and Knitr 2nd ed. Chapman; Hall/CRC, Boca Raton, Florida. Retrieved from https://yihui.org/knitr/
Xie Y (2021a). Animation: A Gallery of Animations in Statistics and Utilities to Create Animations. Retrieved from https://yihui.org/animation/
Xie Y (2021b). Knitr: A General-Purpose Package for Dynamic Report Generation in r. Retrieved from https://yihui.org/knitr/
Xie Y, Allaire JJ, Grolemund G (2018). R Markdown: The Definitive Guide. Chapman; Hall/CRC, Boca Raton, Florida. Retrieved from https://bookdown.org/yihui/rmarkdown
Xie Y, Dervieux C, Riederer E (2020). R Markdown Cookbook. Chapman; Hall/CRC, Boca Raton, Florida. Retrieved from https://bookdown.org/yihui/rmarkdown-cookbook

Appendix

Thank you so much for reading this work!